package com.stevenmoon.csdnplus.fragment.base;

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import com.hannesdorfmann.mosby.mvp.MvpPresenter;
import com.hannesdorfmann.mosby.mvp.MvpView;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic;
import com.stevenmoon.csdnplus.R;

/**
 * Created by WangJun on 2016/4/10.
 */
public abstract class ToolbarBaseFragment<V extends MvpView, P extends MvpPresenter<V>> extends MvpBaseFragment<V, P> {

    //@Bind(R.id.toolbar)
    protected Toolbar mToolbar;


    @Override
    protected void initViews() {
        initToolBar();
        setHasOptionsMenu(true);
    }


    protected String getToolbarTitle() {
        return "";
    }

    protected void initToolBar() {
        mToolbar = (Toolbar) mRootView.findViewById(R.id.toolbar);
        ((AppCompatActivity) getActivity()).setSupportActionBar(mToolbar);
        mToolbar.setTitle(getToolbarTitle());
        Drawable menuDra = new IconicsDrawable(getActivity())
                //FIXME 主题相关
                .color(Color.WHITE)
                .icon(MaterialDesignIconic.Icon.gmi_menu)
                .sizeRes(R.dimen.nav_icon_size);
        mToolbar.setNavigationIcon(menuDra);


//        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                getActivity().onBackPressed();
//            }
//        });
    }

}
